import { Behaviour } from "./Behaviour.js";
/**
     * The Behaviour class is the base for the other Behaviour
     *
     * @class Behaviour
     * @constructor
     */
    /**
 * The Behaviour class is the base for the other Behaviour
 *
 * @class Behaviour
 * @constructor
 */
export class Spring extends Behaviour {
    constructor(x, y, z, spring, friction, life, easing) {
        super( life, easing);
        reset(x, y, z, spring, friction);
        this.name = "Spring";
    }
    reset(x, y, z, spring, friction) {
        if (!this.pos)
            this.pos = new Proton.Vector3D(x, y, z);

        else
            this.pos.set(x, y, z);
        this.spring = spring || .1;
        this.friction = friction || .98;
    }
    applyBehaviour(particle, time, index) {
        super.applyBehaviour( particle, time, index);
        particle.v.x += (this.pos.x - particle.p.x) * this.spring;
        particle.v.y += (this.pos.y - particle.p.y) * this.spring;
        particle.v.z += (this.pos.z - particle.p.z) * this.spring;

    }
}




;
